import request from '@/utils/request'

export function createArticle(data) {
  return request({
    url: '/articles',
    method: 'post',
    data
  })
}

export function getArticleList(page, pageSize) {
  return request({
    url: '/articles',
    method: 'get',
    params: { 'page': page, 'page_size': pageSize }
  })
}

export function getArticleListBySearchText(text) {
  return request({
    url: '/articles/query/' + text,
    method: 'get'
  })
}

export function getArticleById(id) {
  return request({
    url: '/articles/editPage/' + id,
    method: 'get'
  })
}
/*
  更新文章
 */
export function updateArticle(id, data) {
  return request({
    url: '/articles/' + id,
    method: 'put',
    data
  })
}
/*
  根据文章id删除文章
 */
export function deleteArticle(id) {
  return request({
    url: '/articles/' + id,
    method: 'delete'
  })
}
